package com.ys.service.Impl;

import com.ys.mapper.CgoderMapper;
import com.ys.mapper.DruMapper;
import com.ys.pojo.*;
import com.ys.service.*;
import com.ys.vo.TuiVo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

@Service("CgoderService")
public class CgoderServiceImpl implements CgoderService {
    @Resource
    private CgoderMapper cgoderMapper;
    @Resource
    private AdministratorsService administratorsService;
    @Resource
    private DruMapper druMapper;
    @Resource
    private CgoderService cgoderService;
    @Resource
    private DrugsService drugsService;
    @Resource
    private DrugssService drugssService;
    @Resource
    private CgospeciService cgospeciService ;
    @Override
    public int adds(Cgoder cgoder) {
        return cgoderMapper.adds(cgoder);
    }

    @Override
    public List<Cgoder> selectCgoder(String ids,String jintui) {
        List<Cgoder> list = cgoderMapper.selectCgoder(jintui);
        list.forEach(x->{
//            System.out.println(x.getQualPer()+"===00000");
                if(x.getQualPer()!=null){
                x.setZhijianren(administratorsService.finalByAllobj(x.getQualPer()).getAnames());
            }
        });
        return list;
    }

    @Override
    public boolean updsdate(String ids) {
        return cgoderMapper.upsdate(ids);
    }

    @Override
    public boolean updsdatessssssssss(String ids) {
        LocalDate riqi = LocalDate.now();
        return cgoderMapper.updsdatessssssssss(riqi,ids);
    }

    @Override
    public boolean updsdss(String id) {
        return cgoderMapper.updsdss(id);
    }

    @Override
    public boolean updszhuangtai(String id) {
        return cgoderMapper.updszhuangtai("退货",id);
    }

    @Override
    public boolean updscomment(String ids) {
        return cgoderMapper.updscomment(ids);
    }

    @Override
    public boolean updscdingdanStar(String dingdanStar,String comment, String ids) {
        return cgoderMapper.updscdingdanStar(dingdanStar,comment,ids);
    }
    //张帅桐做的!!
    @Override
    public List<Cgoder> searchState(String supId) {
        return cgoderMapper.findState(supId);
    }
    @Override
    public List<Cgoder> searchDate(LocalDate localData) {
        return cgoderMapper.findDate(localData);
    }
    /**
     * 查找状态为进货的
     * @return
     */
    @Override
    public List<Cgoder> searchSupId() {
        return cgoderMapper.findSupId();
    }

    /**
     * 查找状态为退货的
     * @return
     */
    @Override
    public List<Cgoder> searchTui() {
        return cgoderMapper.findTui();
    }

    @Override
    public List<Cgoder> searchTuiTime(TuiVo chuTime) {
        return cgoderMapper.findChuTime(chuTime);
    }
}
